"use strict";
const common_vendor = require("../../../../common/vendor.js");
const zeroLazyLoad = () => "../../../zero-lazy-load/components/zero-lazy-load/zero-lazy-load.js";
const uniRate = () => "../../../uni-rate/components/uni-rate/uni-rate.js";
const _sfc_main = {
  components: {
    zeroLazyLoad,
    uniRate
  },
  name: "zero-waterfall",
  props: {
    // 需要在使用页面 onPageScroll 传进来
    list: {
      type: Array,
      required: true,
      default: []
    },
    // 图片裁剪模式
    imgMode: {
      type: String,
      default: "widthFix"
    }
  },
  data() {
    return {
      listLeft: [],
      listRight: [],
      newList: []
    };
  },
  watch: {
    list(newValue, oldValue) {
      this.newList = newValue.slice(oldValue.length);
      this.considerPush();
    }
  },
  mounted() {
    this.init();
  },
  methods: {
    // 触发重新排列
    init() {
      this.newList = [...this.list];
      this.listLeft = [];
      this.listRight = [];
      if (this.newList.length != 0) {
        this.listLeft.push(this.newList.shift());
      }
    },
    // 清空数据列表
    clear() {
      this.listLeft = [];
      this.listRight = [];
      this.$emit("clear", []);
      this.newList = [];
    },
    // 计算排列
    considerPush() {
      if (this.newList.length == 0)
        return;
      let leftH = 0, rightH = 0;
      var query = common_vendor.index.createSelectorQuery().in(this);
      query.selectAll(".waterfall_left").boundingClientRect();
      query.selectAll(".waterfall_right").boundingClientRect();
      query.exec((res) => {
        leftH = res[0].length != 0 ? res[0][0].height : 0;
        rightH = res[1].length != 0 ? res[1][0].height : 0;
        if (leftH == rightH || leftH < rightH) {
          this.listLeft.push(this.newList.shift());
        } else {
          this.listRight.push(this.newList.shift());
        }
      });
    },
    gotoConsultantDetail(id) {
      common_vendor.index.navigateTo({
        url: "/pages/consultant-detail/consultant-detail?id=" + id
      });
    }
  }
};
if (!Array) {
  const _easycom_zero_lazy_load2 = common_vendor.resolveComponent("zero-lazy-load");
  const _easycom_uni_rate2 = common_vendor.resolveComponent("uni-rate");
  (_easycom_zero_lazy_load2 + _easycom_uni_rate2)();
}
const _easycom_zero_lazy_load = () => "../../../zero-lazy-load/components/zero-lazy-load/zero-lazy-load.js";
const _easycom_uni_rate = () => "../../../uni-rate/components/uni-rate/uni-rate.js";
if (!Math) {
  (_easycom_zero_lazy_load + _easycom_uni_rate)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return {
    a: common_vendor.f($data.listLeft, (item, index, i0) => {
      return common_vendor.e({
        a: item.consultState === 0
      }, item.consultState === 0 ? {} : {}, {
        b: item.consultState === 1
      }, item.consultState === 1 ? {} : {}, {
        c: common_vendor.o($options.considerPush, index),
        d: common_vendor.o($options.considerPush, index),
        e: "19530492-0-" + i0,
        f: common_vendor.p({
          image: item.consultantAvatar,
          imgMode: $props.imgMode,
          borderRadius: "1000"
        }),
        g: common_vendor.t(item.consultantName),
        h: common_vendor.t(item.helpCount),
        i: "19530492-1-" + i0,
        j: common_vendor.p({
          readonly: true,
          value: item.averageRank
        }),
        k: common_vendor.t(item.briefIntroduction),
        l: common_vendor.f(item.expertiseTag, (itemtag, index2, i1) => {
          return {
            a: common_vendor.t(itemtag.tagName),
            b: index2
          };
        }),
        m: index,
        n: common_vendor.o(($event) => $options.gotoConsultantDetail(item.id), index)
      });
    }),
    b: common_vendor.f($data.listRight, (item, index, i0) => {
      return common_vendor.e({
        a: item.consultState === 0
      }, item.consultState === 0 ? {} : {}, {
        b: item.consultState === 1
      }, item.consultState === 1 ? {} : {}, {
        c: common_vendor.o($options.considerPush, index),
        d: common_vendor.o($options.considerPush, index),
        e: "19530492-2-" + i0,
        f: common_vendor.p({
          image: item.consultantAvatar,
          imgMode: $props.imgMode,
          borderRadius: "1000"
        }),
        g: common_vendor.t(item.consultantName),
        h: common_vendor.t(item.helpCount),
        i: "19530492-3-" + i0,
        j: common_vendor.p({
          readonly: true,
          value: item.averageRank
        }),
        k: common_vendor.t(item.briefIntroduction),
        l: common_vendor.f(item.expertiseTag, (itemtag, index2, i1) => {
          return {
            a: common_vendor.t(itemtag.tagName),
            b: index2
          };
        }),
        m: index,
        n: common_vendor.o(($event) => $options.gotoConsultantDetail(item.id), index)
      });
    })
  };
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-19530492"], ["__file", "D:/Project/heart-3.0/heart-field-3.0/uni_modules/zero-waterfall/components/zero-waterfall/zero-waterfall.vue"]]);
wx.createComponent(Component);
